class LoginController < ApplicationController
  skip_before_filter :authenticate, :only => [:enter]

  def enter
    if request.post?
      if user = Usuario.find_by_login_and_senha(params[:login],params[:password])
        session[:user] = user.id
        redirect_to session[:return_to]
      else
        flash[:notice] = "O usuário/senha não confere."
      end
    end
  end
  
  def sair
    session[:user] = nil
    redirect_to "/inicios"
  end
end
